import scrapy


class ProducerSpider(scrapy.Spider):
    name = "producer"
    # allowed_domains = ["a.com"]
    # start_urls = ["https://chat.deepseek.com/"]

    async def start(self):
        url = "https://quotes.toscrape.com/"
        yield scrapy.Request(url, callback=self.parse)


    def parse(self, response):
        items = response.xpath('//div[@class="quote"]')
        for item in items:
            data = {
                "author": item.xpath('.//small/text()').get(),
                "text": item.xpath('.//span[@class="text"]/text()').get()[1:-1],
                "tags": item.xpath('.//div/a/text()').getall(),
            }
            # print(data)
            yield {
                "author": item.xpath('.//small/text()').get(),
                "text": item.xpath('.//span[@class="text"]/text()').get()[1:-1],
                "tags": item.xpath('.//div/a/text()').getall(),
            }

        next_url = response.xpath('//li[@class="next"]/a/@href').get()
        if next_url:

            yield response.follow(next_url)